package cn.demon.basic.service.impl;

import cn.demon.basic.service.IBaiduAiAuditService;
import cn.demon.basic.util.BaiduAuditUtils;
import org.springframework.stereotype.Service;

/**
 * 百度Ai审核实现类
 */
@Service
public class BaiduAiAuditServiceImpl implements IBaiduAiAuditService {


    @Override
    public Boolean textAudit(String auditText) {
        //@TODO - 自主研发 - 工具类BaiduAuditUtils
        if (auditText != null) {
            Boolean aBoolean = BaiduAuditUtils.TextCensor(auditText);
            return aBoolean;
        }
        return true;
    }

    /*
     *  注意:resources是这样的格式：
     *  /group1/M00/00/02/CgAIC2KevEeAX2T4AAEUusLjqqk161.png,/group1/M00/00/02/CgAIC2KevEeAX2T4AAEUusLjqqk162.png
     *  需要判断是否为空，只有一张怎么处理，有多张怎么处理
     *  需要统一加前缀：http://123.207.27.208
     */
    @Override
    public Boolean imageAudit(String resources) {
        //@TODO - 自主研发 - 工具类BaiduAuditUtils
        Boolean aBoolean = null;
        String surfix = "http://123.207.27.208";
        if (resources != null) {
            String[] resource = resources.split(",");
            for (String s : resource) {
                String str = surfix + s;
                aBoolean = BaiduAuditUtils.ImgCensor(str);
                if (!aBoolean) {
                    return false;
                }
            }
        }
        return true;
    }

}